var app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        showContact: true,
        suspendShow: true,
        showIcon: true,
        bg1color: '',
        bookDetails_box: !1,
        isSydw: false,
        myPhone: "",
        showIcon: !0,
        isShowAuth: !1,
        yl: 1,
        ziliaobox: 0,
        isSydw: false,
        login: true,
        chaxunbox: 0,
        islogin: 0,
        bgcolor: '#fff',
        color: '#000',
        opacity: '0.6',
        bottom: '30%',
        imgUrl: '',
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: async function (options) {
        await app.methods.getPhoneNumber()
        xhs.showShareMenu({
          shareTypes: 'normal',
        })
        this.setData({
            options: options
        })
        let newHref = '';
        newHref = options.href + (options.phone ? '?phone=' + options.phone : '')
        newHref = newHref + (options.gonghao ? '&gonghao=' + options.gonghao : '')
        newHref = newHref + (options.fenxiao ? '&fenxiao=' + options.fenxiao : '')
        newHref = newHref + (options.wxh ? '&wxh=' + options.wxh : '')
        newHref.replace(/&amp;/g, "&")
        this.setData({
            href: newHref
        })
        await this.getHdInfo(this.data.options.xm)
    },
    // 加载内容
    async getHdInfo(xiangmu) {
        return new Promise((resolve) => {
            xhs.request({
                url: 'https://zg99.offcn.com/index/chaxun/getfzinfo/?actid=47204&callback=&shijian=' + Date.parse(new Date()) / 1000,
                type: 'GET',
                dataType: 'jsonp',
                data: {
                    xiangmu: xiangmu,
                },
                success: ((res) => {
                    let newStr = res.data.substring(1);
                    newStr = JSON.parse(newStr.substring(0, newStr.length - 1))
                    // console.log(newStr)
                    if (newStr.status == 1) {
                        this.setData({
                            imgUrl: !newStr.lists[0].imgUrl ? this.data.imgUrl : newStr.lists[0].imgUrl,
                        })
                    }
                    resolve()
                })
            })
        })
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {},

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {},

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {
        return {
            path: `/packageA/zt/zt?xm=${this.data.options.xm}&fenxiao=${this.data.options.fenxiao}&gonghao=${this.data.options.gonghao}&wxh=${this.data.options.wxh}`,
            imageUrl: this.data.imgUrl,
        }
    }
})